//2009/08/22 01:27:30
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class BettingStrategy
{
public:
    int finalSum(int initSum, string outcome)
    {
		//LLWLLWWWWLLLLLWLLWLLLWWLW
        int sum = initSum;
        int bet = 1;
        for (int i=0; i<outcome.size(); i++)
        {
			if (sum < bet) return sum;
            if (outcome[i] == 'W')
            {
                sum += bet;
                bet = 1;
            }
            else
            {
                sum -= bet;
                bet *= 2;
            }
			cout << "Sum: " << sum << endl;
        }
        return sum;
    }
};
